Ví dụ MathML

Công thức bậc hai:

x = − b ± b 2 − 4 a c 2 a {\displaystyle x={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}}

Vốn được viết theo ngữ pháp TeX:

x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Sẽ có thể được viết bằng MathML:

<math> <mrow>  <mi>x</mi>  <mo>=</mo>  <mfrac>    <mrow>      <mrow>        <mo>-</mo>        <mi>b</mi>      </mrow>      <mo>±</mo>      <msqrt>        <mrow>          <msup>            <mi>b</mi>            <mn>2</mn>          </msup>          <mo>-</mo>          <mrow>            <mn>4</mn>            <mo>⁢</mo>            <mi>a</mi>            <mo>⁢</mo>            <mi>c</mi>          </mrow>        </mrow>      </msqrt>    </mrow>    <mrow>      <mn>2</mn>      <mo>⁢</mo>      <mi>a</mi>    </mrow>  </mfrac> </mrow></math>

Nếu muốn hiển thị đúng trong trình duyệt Mozilla, cần thêm

<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [ <!ENTITY mathml "http://www.w3.org/1998/Math/MathML"> ] >

Và lưu giữ các mã này trong tập tin có đuôi .xml.

Như trong ví dụ trên:

<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [ <!ENTITY mathml "http://www.w3.org/1998/Math/MathML"> ] ><body><math xmlns="&mathml;"><mrow>  <mi>x</mi>  <mo>=</mo>  <mfrac>    <mrow>      <mrow>        <mo>-</mo>        <mi>b</mi>      </mrow>      <mo>±</mo>      <msqrt>        <mrow>          <msup>            <mi>b</mi>            <mn>2</mn>          </msup>          <mo>-</mo>          <mrow>            <mn>4</mn>            <mo>⁢</mo>            <mi>a</mi>            <mo>⁢</mo>            <mi>c</mi>          </mrow>        </mrow>      </msqrt>    </mrow>    <mrow>      <mn>2</mn>      <mo>⁢</mo>      <mi>a</mi>    </mrow>  </mfrac></mrow></math></body>